package vip.mall.modular.orderAddress.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.mall.modular.orderAddress.entity.OrderAddress;
import vip.mall.modular.orderAddress.mapper.OrderAddressMapper;
import vip.mall.modular.orderAddress.params.AddOrderAddressParams;
import vip.mall.modular.orderAddress.service.OrderAddressService;


/**
 * @author ASUS
 * @Date 2025/2/21 22:15
 * @Descripition
 */
@Service
public class OrderAddressServiceImpl extends ServiceImpl<OrderAddressMapper, OrderAddress> implements OrderAddressService {
    @Override
    public boolean add(AddOrderAddressParams addOrderAddressParams) {
        OrderAddress orderAddress = BeanUtil.copyProperties(addOrderAddressParams, OrderAddress.class);
        return save(orderAddress);
    }

    @Override
    public OrderAddress selectOrderAddressByUserId(String userId) {
        LambdaQueryWrapper<OrderAddress> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(OrderAddress::getUserId, userId);
        return getOne(lambdaQueryWrapper);
    }
}
